package com.jeesite.modules.own.web;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.jeesite.modules.own.utils.HttpClient1;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.shiro.authz.annotation.RequiresGuest;
import org.apache.shiro.authz.annotation.RequiresUser;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/own/query")
public class QueryController {

    @Value("${qkurl.vertifyUrl}")
    private  String vertifyUrl;

    @Value("${qkurl.getfromdbUrl}")
    private String getfromdbUrl;

    @RequestMapping(value = "getVertify")
    @ResponseBody
    public String getVertify(String txid){
        String content="";
        if(txid==null){
           content="缺少txid";
        }else{

            String s = HttpClient1.doGet(vertifyUrl + txid);
            System.out.println(s);
            JSONObject jsonObject = JSON.parseObject(s);
            JSONObject datas = (JSONObject) jsonObject.get("datas");
            content = datas.toJSONString();
            System.out.println("content"+content);
        }
        return content;
    }

    @RequestMapping(value="getfromdb")
    @ResponseBody
    public String getFromdb(String uuid){
        String content="";
        if(uuid==null){

            content="缺少uuid";

        }else{

            JSONObject map = new JSONObject();
            map.put("uuid",uuid);
            String s = HttpClient1.doPost(getfromdbUrl, map.toJSONString());
            JSONObject jsonObject = JSON.parseObject(s);
            content = jsonObject.toJSONString();
        }
        return content;

    }

}
